<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Page Config->DB-Backup
 * db-Backup
 * use backup.page.class.php
 *     backup.tpl.php
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
function contentPage($refPage, $page, $subpage, $refValidate)
{
	if (isset($_GET['func']))
	{
		if ($refValidate->cleanslash($_REQUEST['submit']) === _('Start database backup'))
		{ // create backup-file
			include_once('module/class/backup.class.php');
			$backup = new backup();
			$_SERVER["bmessage"] = _('Backup startet...') . '<br>';
			if (backup::startBackup())
				message::setNoteRow(_('Backup file sent successfully'), TRUE);
			else
				message::setErrorRow(_('Error creating or sending the backup!'), TRUE);

			$refPage->assign('backupMessage',
				'<span id="bMessage">' .
				$_SERVER["bmessage"] . '</span>');
		}
	}
	else
	{
		$refPage->assign('backupMessage', '');

		$refPage->assign('btnBackupDb',
			'<input type="submit" name="submit" id="backup" value="' .
			_('Start database backup') . '" />');
	}

	$refPage->assign('text',
		_('Click on the button "Start database backup" is a 1:1 copy of your ' .
			'database generated. This backup file is automatically sent ' .
			'to the Administrator-mail address specified in the backend.'));

	$pagefile = 'module/page/' . $page . '/' . $subpage . '.page.form.php';
	if (is_file($pagefile))
		include_once $pagefile;
}

?>